package com.zhuiyi.yiqingbackend.common;

import lombok.Data;

import java.io.Serializable;

/**
 * 通用返回类 第一步：定义一个类，继承Serializable接口
 *
 * @param <T>
 * @author zhuiyi
 * description:返回给前端的消息先包装一下 针对 Controller层的返回值类型！！
 */
//生成get set方法
@Data
public class BaseResponse<T> implements Serializable {//泛型 <T>  序列化
    private int code;
    private T data;
    private String message;
    private String description;

    public BaseResponse(int code, T data, String message, String description) {
        this.code = code;
        this.data = data;
        this.message = message;
        this.description = description;
    }


    public BaseResponse(int code, T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public BaseResponse(int code, T data) {
        this.code=code;
        this.data=data;
    }

    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(), null, errorCode.getMessage(), errorCode.getDescription());
    }

    public BaseResponse(int code, String message) {
        this.code = code;
        this.message = message;
    }


}
